
/*========================================================================================
 *                                                                                      *
 *               Copyright(c) 2013-2014, Cha SangWoo, All rights reserved.              *
 *                                                                                      *
 * This file is part of ChaOS.                                                          *
 *                                                                                      *
 * Permission to use, copy, modify, and distribute this software in source and binary   *
 * forms and its documentation for any purpose and without fee is hereby granted,       *
 * provided that the above copyright notice appear in all copies and that both that     *
 * copyright notice and this permission notice appear in supporting documentation.      *
 *                                                                                      *
 * THIS SOFTWARE IS PROVIDED BY THE CHA SANGWOO AND CONTRIBUTORS "AS IS" AND ANY        *
 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED            *
 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.   *
 * IN NO EVENT SHALL CHA SANGWOO OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,    *
 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT         *
 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,          *
 * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF            *
 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE      *
 * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,                    *
 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.                                   *
 *                                                                                      *
========================================================================================*/

#ifndef __CO_QUEUE_H__
#define __CO_QUEUE_H__

#if (FLAG_USE_CHAOS_QUEUE == CO_ENABLE)

#include "co_types.h"

#ifdef __cplusplus
    extern "C" {
    namespace ChaOS {
#endif

//////////////////////////////////////  < BEGIN >  ///////////////////////////////////////

/*======================================================================================*/
/*!
    @fn             OBJECT co_queue_create(UINT item_size, UINT item_count)

    @brief          

    @param [in]     item_size  - 
    @param [in]     item_count - 

    @return         Object for queue
*/
/*======================================================================================*/
OBJECT co_queue_create(UINT item_size, UINT item_count);


/*======================================================================================*/
/*!
    @fn             CO_RESULT co_queue_send(OBJECT object, VOID *pitem, BOOL overwrite)

    @brief          

    @param [in]     object - Object for queue
    @param [in]     pitem  - 

    @return         None
*/
/*======================================================================================*/
CO_RESULT co_queue_send(OBJECT object, VOID *pitem, UINT16 timeout);


/*======================================================================================*/
/*!
    @fn             CO_RESULT co_queue_recv(OBJECT object, VOID *pitem, UINT16 timeout)

    @brief          

    @param [in]     object  - Object for queue
    @param [in]     pitem   - 
    @param [in]     timeout - 

    @return         CO_RESULT value
*/
/*======================================================================================*/
CO_RESULT co_queue_recv(OBJECT object, VOID *pitem, UINT16 timeout);


/*======================================================================================*/
/*!
    @fn             UINT16 co_queue_get_item_size(OBJECT object)

    @brief          Get size of item in queue

    @param [in]     object  - Object for queue

    @return         Size of item in queue
*/
/*======================================================================================*/
UINT16 co_queue_get_item_size(OBJECT object);


/*======================================================================================*/
/*!
    @fn             UINT16 co_queue_get_item_count(OBJECT object)

    @brief          Get count of items in queue

    @param [in]     object - Object for mutex

    @return         Count of items in queue
*/
/*======================================================================================*/
UINT16 co_queue_get_item_count(OBJECT object);


/*======================================================================================*/
/*!
    @fn             VOID co_queue_flush(OBJECT object)

    @brief          Clear queue. The items in queue will be delete.

    @param [in]     object - Object for queue

    @return         None
*/
/*======================================================================================*/
VOID co_queue_flush(OBJECT object);


//////////////////////////////////////  <  END  >  ///////////////////////////////////////

#ifdef __cplusplus
    } /* namespace ChaOS */
    } /* extern "C" */
#endif

#endif // (FLAG_USE_CHAOS_QUEUE == CO_ENABLE)

#endif //__CO_QUEUE_H__

